<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <title>个人信息</title>
    <link rel="stylesheet" href="../../bower_components/font-awesome/css/font-awesome.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="../../dist/css/AdminLTE.min.css">

    <link rel="stylesheet" type="text/css" href="http://apps.bdimg.com/libs/bootstrap/2.3.2/css/bootstrap.min.css">

    <link rel="stylesheet" href="../../outlink/selectpage.css" type="text/css">

    <link rel="stylesheet" href="../../outlink/demo.css"/>

    <link rel="stylesheet" href="../../outlink/pagination.css"/>
</head>
<style>
    body {
        background-image: url("../../outlink/img/plane_myths_big.jpg");
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        min-width: 1000px;
        z-index: -10;
        zoom: 1;
        background-color: #fff;
        background-repeat: no-repeat;
        background-size: cover;
        -webkit-background-size: cover;
        -o-background-size: cover;
        background-position: center 0;
    }
</style>
<body>
<div>
    <h3>
<a th:href="@{/index/user2}">查看订单信息</a><br><br>
<a th:href="@{/index/user3}">查看需求信息</a><br><br>
<a th:href="@{/index/hello2}">去订票</a><br><br>
    </h3>
</div>
<div class="top" style="height:35px;width: 100%;">
    <div class="loginSuccess" id="loginSuccess" style="float: right;margin-right: 10px;margin-top: 10px">
        <!--登录成功后显示用户信息-->
    </div>
</div>
<div class="middle" style="margin-left: 50px">
    <section style="width: 70%;float: right">
        <center>
            <span style="font-size: 35px">个人信息</span></br>
            <table border="1" id="resinfo" class="table table-bordered table-hover" style="margin-left: 50px">
                <tr>
                    <th style="width:20%">用户名</th>
                    <th style="width:20%">姓名</th>
                    <th style="width:20%">年龄</th>
                    <th style="width:20%">性别</th>
                </tr>
                <tbody id="userInfo">

                </tbody>
            </table>

        </center>


    </section>
</div>
</body>
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script src="../../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="../../outlink/jquery.pagination.js"></script>
<script src="../../outlink/jquery.cookie.js"></script>
<script th:inline="javascript">
    var isCookie = $.cookie('username'); // 读取"userName"的cookie值
    //网页加载时运行
    window.onload = function () {
        var html = "";     //添加用户信息
        html += " <span class=\"hidden-xs\" style='font-size:30px ' >欢迎您&nbsp;</span>";
        html += " <span class=\"hidden-xs userinfo\" id=\"uname\" style='color: black;font-size:30px '>" + isCookie + "</span>";
        html += "   ";
        html += "<input type=\"button\" id=\"loginoutbtn\" class=\"btn btn-info \" value=\"退出\" />";
        $('#loginSuccess').html(html);

        //查询用户信息
        var p_userInfo = {"str": isCookie, "pageNum": 0}
        $.ajax({
            type: "post",
            url: "../userinfo/selectUserInfo",
            data: JSON.stringify(p_userInfo),
            contentType: "application/json; charset=utf-8",
            type: "json",
            success: function (result) {
                if (result.status == 0) {
                    console.log(result);
                    var html2 = "";
                    var listinfo = result.data;  //后端返回用户信息
                    if (listinfo.uName != "") {   //展示用户信息
                        if (listinfo.uSex == 1) {
                            listinfo.uSex = "女";
                        } else {
                            listinfo.uSex = "男";
                        }
                        html2 += "<tr>";
                        html2 += "<td>";
                        html2 += listinfo.uUsername;
                        html2 += "</td>";
                        html2 += "<td>";
                        html2 += listinfo.uName;
                        html2 += "</td>";
                        html2 += "<td>";
                        html2 += listinfo.uAge;
                        html2 += "</td>";
                        html2 += "<td>";
                        html2 += listinfo.uSex;
                        html2 += "</td>";
                        html2 += "</tr>";
                        $("#userInfo").html(html2);
                    } else {
                        alert("个人信息查询失败，请重试");
                    }

                }
                if (result.status == -1) {
                    alert(result.msg);
                    $("#userOrder").html("");
                    $('#myModal').modal('hide');
                }
            },
            error: function () {
                alert("查询失败，请重试");
            }
        })
        //退出操作
        $('#loginoutbtn').click(function () {
            console.log("已退出");
            $.cookie("username", "", -1);  //退出时删除cookie并刷新网页
            window.location.href = "../index/plane"; //跳转首页
        })
    }


</script>
</html>